package com.gxa.web.ServiceManagement;

import com.alibaba.fastjson.JSONObject;
import com.gxa.common.R;
import com.gxa.pojo.ServiceManagementInfo;
import com.gxa.service.ServiceService;
import com.gxa.service.impl.ServiceServiceImp;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

//修改归档数据
@WebServlet("/service/updateArchiving")
public class UpdateServiceArchivingServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //获取edit.html页面中表单值
        String id = request.getParameter("id");
        String service_name = request.getParameter("service_name");
        String service_type = request.getParameter("type");
        Date date = new Date();
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String str = df.format(date);
        String operator = request.getParameter("dopeople");

        String pending_person = request.getParameter("waitpeople");
        String customer_content = request.getParameter("customer_content");
        String note_information = request.getParameter("note_information");
        //把数据塞入House对象中
        ServiceManagementInfo serviceManagementInfo = new ServiceManagementInfo();
        serviceManagementInfo.setId(Integer.parseInt(id));
//        serviceManagementInfo.setService_name(service_name);
//        serviceManagementInfo.setService_type(service_type);
////        serviceManagementInfo.setService_status(3);
//        serviceManagementInfo.setLast_operation_time(date);
//        serviceManagementInfo.setOperator(operator);
//        serviceManagementInfo.setPending_person(pending_person);
//        serviceManagementInfo.setService_customers(customer_content);
        serviceManagementInfo.setLast_operation_time(str);
//        serviceManagementInfo.setNote_information(note_information);

        //调用service
        ServiceService serviceService = new ServiceServiceImp();
        R r = serviceService.updateServiceArchivingById(serviceManagementInfo);
        //响应R
        response.setContentType("application/json;charset=utf-8");
        response.getWriter().write(JSONObject.toJSONString(r));
    }
}
